<%@ include file="include.jsp"%>
<body>
	<h1>Create Template</h1>
	<form:form id="save_template" action="/template/save_template"
		method="post" modelAttribute="template">
		<form:hidden path="id" />
		<table>
			<tr>
				<td><form:label id="titleLabel" path="title">Title : </form:label></td>
				<td><form:input id="title" path="title" /></td>
			</tr>

			<tr>
				<td><form:label id="valueLabel" path="value">Value : </form:label></td>
				<td><form:textarea id="value" path="value"
						style="width: 958px; height: 291px;" /></td>
			</tr>
			<tr>
				<td><form:label id="typeLabel" path="type">Type : </form:label></td>
				<td>
					<form:select path="type">
						<form:option value="-" label="--Please Select" />
						<form:options items="${types}" />
					</form:select>
				</td>
			</tr>
		</table>
		<p id="error"></p>
		<input type="button" value="Save" onclick="checkValuesBeforeSubmit()" />
		<input type="reset" value="Cancel" />
	</form:form>
</body>
<script type="text/javascript">
	function checkValuesBeforeSubmit() {
		var isOk = true;
		if (isOk) {
			document.forms["save_template"].submit();
		} else {
			document.getElementById("error").innerHTML = "You must fill in all this attributes with (*)";
		}
	}
</script>
</html>
